<template>
  <div class="custom-head">
    <div class="top">
      <img class="logo" src="../assets/logo.png" alt="" @click="toHome">
      <div class="right">
        <div class="search">
          <div class="left">
            <img src="../assets/search-icon.png" alt="">
            <el-input v-model="searchTxt" placeholder="搜索"></el-input>
          </div>
          <el-button class="search-btn">检索中心</el-button>
          <el-button class="question-btn" type="text">问答中心</el-button>
        </div>
        <div class="icon">
          <span class="skin-icon">
            <img src="../assets/skin-icon.png" alt="">
          </span>
          <span>
            <img src="../assets/my-icon.png" alt="">
          </span>
          <span @click="sidebarDialog = true">
            <img src="../assets/expansion-fold-icon.png" alt="">
          </span>
        </div>
      </div>
    </div>
    <div class="search-phone">
      <div class="left">
        <img src="../assets/search-icon.png" alt="">
        <el-input v-model="searchTxt" placeholder="搜索"></el-input>
      </div>
      <el-button class="search-btn">检索中心</el-button>
      <el-button class="question-btn" type="text">问答中心</el-button>
    </div>
    <el-dialog title="侧边栏菜单" class="sidebar-dialog" :visible.sync="sidebarDialog" width="30%">
      <div class="navs">
        <p @click="onChangePage(item.path)" v-for="(item, index) in navList" :key="index">
          <span>{{ item.text }}</span>
          <i class="el-icon-arrow-right"></i>
        </p>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'CustomHead',
  data() {
    return {
      sidebarDialog: false,
      searchTxt: "",
      navList: [{
        text: "首页",
        path: "/teacher",
        num: ""
      },
      // {
      //   text: "邮件中心",
      //   path: "",
      //   num: "5"
      // },
      // {
      //   text: "消息中心",
      //   path: "/message-index",
      //   num: "10"
      // },
      {
        text: "应用中心",
        path: "/applicationCenter",
        num: ""
      },
      {
        text: "旧CRP入口",
        path: "",
        num: ""
      },
      {
        text: "金智门户",
        path: "",
      },
      {
        text: "文档中心",
        path: "",
      },
      {
        text: "数据中心",
        path: "",
      }
      ],
    }
  },
  methods: {
    onChangePage(path) {
      if (path != "") {
        this.$router.push(path)
      }
    },
    toHome() {
      this.$router.push("/teacher")
    }
  }
}
</script>

<style scoped lang="scss">
.custom-head {
  .top {
    width: 100%;
    height: 80px;
    background: #0D67BB;
    padding: 0 40px;
    display: flex;
    align-items: center;
    box-sizing: border-box;

    @include respond-to('phone') {
      padding: 0 20px;
    }

    .logo {
      height: 80px;

      @include respond-to('phone') {
        height: 65px;
      }
    }

    &>.right {
      flex: 1;
      display: flex;
      justify-content: space-between;

      @include respond-to('phone') {
        justify-content: flex-end;
      }

      .search {
        display: flex;
        flex: 1;

        @include respond-to('phone') {
          display: none;
        }

        .left {
          background-color: white;
          @include flexStyle;
          padding: 0px 20px;
          box-sizing: border-box;
          margin-left: 70px;
          height: 38px;
          width: 65%;

          @include respond-to('desktop') {
            margin-left: 20px;
          }

          @include respond-to('pad') {
            margin-left: 10px;
          }

          img {
            width: 20px;
            height: 20px;
            flex-shrink: 0;
          }

          .el-input {
            :deep .el-input__inner {
              border: none;
              border-radius: 0;
              height: 38px;

              &:placeholder {
                color: rgba($color: #333333, $alpha: 0.3);
              }
            }

          }
        }

        .search-btn {
          height: 38px;
          background-color: getVar('underLine');
          color: white;
          border-radius: 0;
          border: 1px solid getVar('underLine');
          margin-left: 3px;
        }

        .question-btn {
          color: white;
          position: relative;

          &::after {
            content: '';
            position: absolute;
            left: 0;
            right: 0;
            bottom: 9px;
            border-bottom: 1.3px solid white;
          }
        }
      }

      .icon {
        display: flex;

        .notic-icon {
          width: 26px;
        }

        .skin-icon {
          @include respond-to('phone') {
            display: none;
          }
        }

        &>span {
          position: relative;
          border: 1px solid rgba($color: #FFFFFF, $alpha: 0.2);
          width: 38px;
          height: 38px;
          border-radius: 50%;
          margin-right: 25px;
          @include flexStyle;

          &:nth-child(3) {
            margin-right: 0;
          }

          &:nth-child(3) {
            display: none;
          }

          img {
            width: 24px;

            @include respond-to('phone') {
              width: 20px;
            }
          }

          .dot {
            position: absolute;
            right: -6px;
            top: -3px;
            display: inline-block;
            background-color: red;
            color: white;
            width: 20px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            border-radius: 50%;
          }

          .message-popup {
            display: none;
            position: absolute;
            background-color: white;
            z-index: 21;
            box-shadow: 2px 2px 5px rgba(0, 0, 0, .15);
            border-radius: 5px;
            bottom: -335px;
            height: 320px;
            right: -9px;
            width: 300px;
            padding: 5px 10px;

            .header {
              color: black;
              display: flex;
              justify-content: space-between;
              line-height: 40px;

              .left {
                span:first-child {
                  color: #222;
                  font-weight: 600;
                  margin-right: 3px;
                }

                span:last-child {
                  color: getVar('underLine');

                }
              }

              .right {
                color: getVar('headBg');
              }
            }

            .message-list {
              .item {
                display: flex;
                color: #333;
                border-bottom: 1px dashed #ebebeb;
                padding: 20px 2px;

                img {
                  width: 40px;
                  height: 40px;
                  margin-right: 6px;
                }

                .middle {
                  flex: 1;

                  p:first-child {
                    font-size: 14px;
                  }

                  p:last-child {
                    color: #555555;
                    font-size: 13px;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                  }
                }

                .time {
                  display: flex;
                  flex-direction: column;
                  color: #555555;
                  font-size: 13px;

                  .num {
                    width: 18px;
                    height: 18px;
                    background-color: getVar('noticColor');
                    color: white;
                    border-radius: 50%;
                    line-height: 20px;
                    text-align: center;
                    align-self: flex-end;
                    font-size: 12px;
                    margin-top: 3px;
                  }
                }
              }
            }

            .bottom {
              color: #979696;
              text-align: center;
              margin-top: 10px;
            }
          }

          &:hover {
            .message-popup {
              display: block;
            }
          }

          @include respond-to('phone') {
            width: 30px;
            height: 30px;
            margin-right: 12px;

            &:nth-child(2) {
              margin-right: 8px;
            }

            &:nth-child(3) {
              margin-right: 0;
              display: flex;
            }
          }
        }

      }
    }
  }

  .search-phone {
    background-color: getVar('headBg');
    display: none;
    padding: 10px 20px;

    @include respond-to('phone') {
      display: flex;
    }

    .left {
      background-color: white;
      @include flexStyle;
      padding: 0px 20px;
      box-sizing: border-box;
      height: 32px;
      width: 100%;

      img {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
      }

      .el-input {
        :deep .el-input__inner {
          border: none;
          border-radius: 0;
          height: 32px;

          &:placeholder {
            color: rgba($color: #333333, $alpha: 0.3);
          }
        }

      }
    }

    .search-btn {
      height: 32px;
      background-color: getVar('underLine');
      color: white;
      border-radius: 0;
      border: 1px solid getVar('underLine');
      margin-left: 3px;
      padding: 0 8px;
    }

    .question-btn {
      color: white;
      position: relative;

      &::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: 9px;
        border-bottom: 1.3px solid white;
      }
    }
  }

  &>.navs {
    display: flex;
    align-items: center;
    height: 70px;
    background-color: getVar('headBg');
    color: white;
    padding: 0 40px;
    border-top: 1px solid rgba($color: #fff, $alpha: 0.3);

    @include respond-to('phone') {
      display: none;
    }

    &>div {

      &.active,
      &:hover {
        font-weight: bold;

        a {
          font-weight: bold;

          &:after {
            display: inline-block;
            content: "";
            width: 50px;
            height: 5px;
            background-color: rgba($color: getVar('underLine'), $alpha: 1);
            border-radius: 4px;
            text-align: center;
            margin-top: 3px;
          }
        }
      }

      a {
        position: relative;
        margin-right: 50px;
        display: flex;
        flex-direction: column;
        border-bottom: 3px solid transparent;
        color: rgba($color: #FFFFFF, $alpha: 1);

        .dot {
          position: absolute;
          right: -18px;
          top: -11px;
          background-color: #FF0000;
          width: 22px;
          height: 22px;
          border-radius: 50%;
          font-weight: normal;
          @include flexStyle;
          font-size: 14px;
        }
      }

    }

  }

  .sidebar-dialog {
    :deep .el-dialog {
      position: fixed;
      width: 50% !important;
      right: 0;
      top: 0;
      bottom: 0;
      margin: 0 !important;
      background: rgba($color: #FAFCFE, $alpha: 1);

      .el-dialog__body {
        padding: 0;
      }

      .el-dialog__header {
        display: none;
      }
    }

    .navs {
      display: flex;
      flex-direction: column;
      min-height: 90vh;
      margin-top: 15px;

      p {
        padding: 20px 20px 20px 30px;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

    }

  }
}
</style>
